package common {
public class ContextFunction {

    public static function create(f:Function, ... args):ContextFunction {
        return new ContextFunction(f, args);
    }

    public static function create0(f:Function, args:Array):ContextFunction {
        return new ContextFunction(f, args);
    }

    function ContextFunction(targetFunction:Function, args:Array) {
        _contextArgumnets = args;
        _targetFunction = targetFunction;
    }

    public function func(... args):* {
        var targetArguments:Array =
                _contextArgumnets.concat(args);
        return _targetFunction.apply(this, targetArguments);
    }

    private var _contextArgumnets:Array;

    private var _targetFunction:Function;
}
}